function ViewReport(iReportType, sUrlPrefix, sReportId, sHelpId, sAction, sSnapshotId)
{
switch(iReportType)
{
case 1:

if(sAction=="dblclick")
{
sAction = "filter";
}
var sParams = "helpID=" + CrmEncodeDecode.CrmUrlEncode(sHelpId) + "&action=" + CrmEncodeDecode.CrmUrlEncode(sAction);
if (!IsNull(sSnapshotId))
{
sParams += "&snapshotID=" + CrmEncodeDecode.CrmUrlEncode(sSnapshotId);
}
openObj(Report, sReportId, sParams, sUrlPrefix);
break;

case 3:

if(sAction == "filter" || sAction == "editfilter")
{
alert(LOCID_NON_SRS_FILTERSCHEDULE);
return;
}
var sUrl = sUrlPrefix + prependOrgName("/CRMReports/Download.aspx?id=" + CrmEncodeDecode.CrmUrlEncode(sReportId));

var oFrame = window.document.frames.frmRptView;
if(IsNull(oFrame))
{
oFrame = window.document.createElement("<iframe style='display:none' id='frmRptView' src='" + prependOrgName("/_root/Blank.aspx'></iframe>"));
oFrame = window.document.body.insertBefore(oFrame);

window.setTimeout("window.document.frames.frmRptView.location = \"" + sUrl + "\"", 10);
}
else
{
oFrame.location = sUrl;
}
break;

case 2:

case 4:

if(sAction == "filter" || sAction == "editfilter")
{
alert(LOCID_NON_SRS_FILTERSCHEDULE);
return;
}

var sUrl = sUrlPrefix + prependOrgName("/CRMReports/ViewHandler.aspx?type=" + CrmEncodeDecode.CrmUrlEncode(iReportType) + "&id=" + CrmEncodeDecode.CrmUrlEncode(sReportId));
var oWindowInfo = GetWindowInformation(Report);
openStdWin(sUrl, buildWinName(), oWindowInfo.Width, oWindowInfo.Height, "scrollbars=1,toolbar=1,menubar=1,location=1");
break;
}
}

function DownloadReport(iReportTypeCode, sId)
{

if (iReportTypeCode == 3)
{

alert(LOCID_DOWNLOAD_LINK_URL_ERROR);
return;
}

var url = prependOrgName("/CRMReports/download.aspx?id=" + CrmEncodeDecode.CrmUrlEncode(sId));
var oFrame = window.document.frames.frmRptDownload;
if(IsNull(oFrame))
{
oFrame = window.document.createElement("<iframe style='display:none' id='frmRptDownload' src='" + prependOrgName("'/_root/Blank.aspx'") + "></iframe>");
oFrame = window.document.body.insertBefore(oFrame);

window.setTimeout("window.document.frames.frmRptView.location = \"" + url + "\"", 10)
}
else
{
oFrame.location = url;
}
}

function handleReportDblClick(oEvent)
{

var oTR = oEvent.ObjectRow;

ViewReport(parseInt(oTR.iReportType, 10), oTR.surlprefix, oTR.oid, oTR.sfilename, "dblclick");

oEvent.returnValue = false;
}

function RunReportWizard(sReportId)
{
var iWidth = 800;
var iHeight = 530;

var sUrl = prependOrgName("/WebWizard/WizardContainer.aspx?WizardId=FD24E63E-421A-4b25-9E28-274B4B7A2263");
if (!IsNull(sReportId))
{
sUrl += "&WizardInput=" + CrmEncodeDecode.CrmUrlEncode(sReportId);
}

return openStdDlg(sUrl, null, iWidth, iHeight, true);
}

function IsValidReportName(sReportName)
{

if (IsNull(sReportName) || sReportName.length == 0)
{
return false;
}



if (!IsNull(sReportName.match('[;\\?:@&=\\+\\$,\\\\\\*<>\\|"\\/]')) || IsNull(sReportName.match('[^ .]')))
{
return false;
}

return true;
}